<?php 
    if (isset($_COOKIE['userid']) && isset($_COOKIE['usermd5']))
    {
        if ($_POST)
        {
            $videoID = $_POST['videoID'];
            $listname = $_POST['listname'];
            $userID = $_COOKIE['userid'];
    		require('config.php');
            if ($listname == '所有收藏')
            {
    		    $stmt = $connection->prepare("delete from user_fav where user_id=? and video_id=?");
    		    $stmt->bind_param("ss", $userID, $videoID);
    		    $stmt->execute();
            }
            else
            {
    		    $stmt = $connection->prepare("delete from user_fav where user_id=? and video_id=? and fav_type=?");
    		    $stmt->bind_param("sss", $userID, $videoID, $listname);
    		    $stmt->execute();
            }
            echo 'SUCCESS';
            $connection->close();
        }
        else
        {
            echo "NOPOST";
        }
    }
    else
    {
        echo 'NOUSER';
    }
?> 
